//
//  HomePageTableViewCell.m
//  CapriceMusic
//
//  Created by dllo on 16/1/7.
//  Copyright © 2016年 MYX. All rights reserved.
//

#import "HomePageTableViewCell.h"

@implementation HomePageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.officiaImageView = [[UIImageView alloc] initWithFrame:CGRectZero];

        [self addSubview:self.officiaImageView];
        
        self.myView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.myView.contentMode = UIViewContentModeScaleToFill;
        [self.officiaImageView addSubview:self.myView];
        
        self.typeImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.officiaImageView addSubview:self.typeImageView];
        
        self.title = [[UILabel alloc] initWithFrame:CGRectZero];
        self.title.textColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
        self.title.font = [UIFont systemFontOfSize:13];
        self.title.numberOfLines = 0;
        [self.officiaImageView addSubview:self.title];
        
        self.descriptions = [[UILabel alloc] initWithFrame:CGRectZero];
        self.descriptions.textColor = [UIColor colorWithRed:30 / 255.0 green:195 / 255.0 blue:153 / 255.0 alpha:1.0];
        self.descriptions.font = [UIFont systemFontOfSize:15];
        [self.officiaImageView addSubview:self.descriptions];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.officiaImageView.frame = self.bounds;
    
    self.myView.frame = self.bounds;
    
    self.typeImageView.frame = CGRectMake(15, self.officiaImageView.bottom - 70, 45, 45);
    
    self.title.frame = CGRectMake(70, self.typeImageView.origin.y - 10, self.width - 70, 40);
    
    self.descriptions.frame = CGRectMake(70, self.typeImageView.origin.y + 15, self.bounds.size.width - 70, 46);
}

- (void)setOfficialModel:(OfficialRecommendModel *)officialModel {
    if (_officialModel != officialModel) {
        _officialModel = officialModel ;
    }
    [self.officiaImageView sd_setImageWithURL:[NSURL URLWithString:officialModel.posterPic]];
    
    if ([officialModel.typeq isEqualToString:@"PLAYLIST"]) {
        self.typeImageView.image = [UIImage imageNamed:@"YueD"];
    } else if ([officialModel.typeq isEqualToString:@"VIDEO"]) {
        self.typeImageView.image = [UIImage imageNamed:@"ShouB"];
    } else if ([officialModel.typeq isEqualToString:@"PROGRAM"] || [officialModel.typeq isEqualToString:@"FANART"]) {
        self.typeImageView.image = [UIImage imageNamed:@"JieM"];
    } else if ([officialModel.typeq isEqualToString:@"ACTIVITY"]) {
        self.typeImageView.image = [UIImage imageNamed:@"HuoD"];
    } else if ([officialModel.typeq isEqualToString:@"WEEK_MAIN_STAR"]) {
        self.typeImageView.image = [UIImage imageNamed:@"Star"];
    } else if ([officialModel.typeq isEqualToString:@"INVENTORY"]) {
        self.typeImageView.image = [UIImage imageNamed:@"ZhuanT"];
    }
    
    self.myView.image = [UIImage imageNamed:@"Jianbian"];
    self.title.text = officialModel.title;
    self.descriptions.text = officialModel.descriptions;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
